package cn.catpd.dozerdemo;

import org.dozer.DozerConverter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wjn
 * @date 2021/12/11 10:52
 */
public class String2ListDozer extends DozerConverter<List, String> {


    public String2ListDozer() {
        super(List.class, String.class);
    }

    public String convertTo(List strings, String s) {
        return String.join(",",strings);
    }

    public List<String> convertFrom(String s, List strings) {
        if(s != null){
            String[] split = s.split(",");
            return Arrays.asList(split);
        }
        return new ArrayList<String>();
    }
}
